package com.study.leetcode;

public class Solution_2744 {
    public int maximumNumberOfStringPairs(String[] words) {
        int ans = 0;
        for (int i = 0; i < words.length; i++) {
            for (int j = i + 1; j < words.length; j++) {
                if (reverseEqual(words[i], words[j])) {
                    ans++;
                }
            }
        }
        return ans;
    }

    private boolean reverseEqual(String word, String word1) {
        return word.charAt(0) == word1.charAt(1) && word.charAt(1) == word1.charAt(0);
    }

    public static void main(String[] args) {
        Solution_2744 solution2744 = new Solution_2744();
        String[] words = {"cd", "ac", "dc", "ca", "zz"};
        System.out.println("ans =" + solution2744.maximumNumberOfStringPairs(words));
    }
}
